<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
	<title>菜单管理</title>
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
        
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>
    
    
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgcore.min.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/lhdialog/lhgdialog.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/OpenDialog.js"></script>

    <script type="text/javascript">
    
     $(document).ready(function() {
    	
    	$('#defaultForm')
        .bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                "t.regex": {
                    validators: {
                        notEmpty: {
                            message: '属性规则不能为空'
                        }
                    }
                }
            }
        })
    }); 
  
  //选择界面（弹出框）
    function choose(entity){
	  	var flag =1;
	  	var pojo=entity;
	  	var page;
	  	
	  	if(pojo=='brandShow'){
	  	    page = 	"<%=request.getContextPath()%>/brandShow/BrandShow_findBrandsByCategory.action?params=choose&categoryId=${t.category.id}";
        }
	  	if(pojo=='productAttr'){
	  	    page = 	"<%=request.getContextPath()%>/productAttr/ProductAttr_listByPage.action?params=choose&t1.category.id=${t.category.id}";
        }
	  	
	  	if(flag == 1){
	  		var titleText = "";
	  		PUBLICOBJECT.id = "entid";
	  		PUBLICOBJECT.title = titleText;
	  		PUBLICOBJECT.width = "1000";
	  		PUBLICOBJECT.height = "auto";
	  		PUBLICOBJECT.titleText = titleText;
	  		PUBLICOBJECT.page = page;
	  		var rs = PUBLICOBJECT.openLab();
	  		rs.ShowDialog();// 打开弹出窗
	  		var dom = window.frames["lhgfrm_" + PUBLICOBJECT.id];// 弹出框document对象
	  		rs.addBtn(PUBLICOBJECT.id, "确定", function() {
	  			var _choose = $(dom.document).find("input[name='idChoose']:checked");
	  			var chooseValue = _choose.val();
	  			if(chooseValue != null){
	  				rs.cancel();// 关闭当弹出窗
	  				var chooseName = _choose.siblings("input[name='nameChoose']").val();
	  				
	  				if(pojo=='brandShow'){
	  			    	$("#brandShowId").val(chooseValue);
	  			    	$("#brandShowName").val(chooseName);
	  		        }
	  		        if(pojo=='productAttr'){
	  			    	$("#productAttrId").val(chooseValue);
	  			    	$("#productAttrName").val(chooseName);
	  		        }
	  			}else{
	  				alert("请选择一项");
	  			}
	  		}, "left");
	  	}
  }
    </script>
</head>
<body>
<div class="panel panel-primary">
  <div class="panel-heading">属性规则维护</div>
  <div class="panel-body">
    
	  <form id="defaultForm" class="form-horizontal" action="<%=request.getContextPath()%>/attrRule/AttrRule_save.action?page=${page }" method="post">
		  <input type="hidden" name="t1.category.id" value="${t1.category.id}">
		  <input type="hidden" name="t1.category.name" value="${t1.category.name}">
		  
		  <div class="form-group">
			  <label for="" class="col-sm-offset-3 col-sm-2 control-label" id="categoryNameMng">类别名称：</label>
			  <div class="col-sm-2">
	              <input class="form-control" type="text" name="t.category.name" id="categoryName" readonly="readonly" onchange="checkCategoryName()" value="${t.category.name }">
	              <input type="hidden" name="t.category.id" id="categoryId" value="${t.category.id}">
			  </div>
		  </div>
	
		  <div class="form-group">
			  <label for="" class="col-sm-offset-3 col-sm-2 control-label" id="brandShowNameMng">选择品牌：</label>
			      <div class="col-sm-2">
	                  <input value="${t.brandShow.name }" class="form-control" type="text" name="t.brandShow.name" id="brandShowName" readonly="readonly" onchange="checkName('brandShowName')">
	                  <input type="hidden" name="t.brandShow.id" id="brandShowId" value="${t.brandShow.id}">
	                  <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
			      </div>
			      <div class="col-sm-1">
	                  <input class="form-control" type="button" value="选择品牌" onclick="choose('brandShow')">
			      </div>
		  </div>
		     
		     
		  <div class="form-group">
			  <label for="" class="col-sm-offset-3 col-sm-2 control-label" id="productAttrNameMng">选择属性：</label>
			     <div class="col-sm-2">
	                <input class="form-control" type="text" name="t.productAttr.name" id="productAttrName" readonly="readonly" value="${t.productAttr.name }" onchange="checkName('productAttrName')">
	                <input type="hidden" name="t.productAttr.id" id="productAttrId" value="${t.productAttr.id}">
	                <div class="check" style="color:#a94442;font-size:85%"><span class="checkMsg"></span></div>
			     </div>
			     <div class="col-sm-1">
	                <input class="form-control" type="button" value="选择属性" onclick="choose('productAttr')">
			     </div>
		  </div>
		     
		  <div class="form-group">
			  <label for="" class="col-sm-offset-3 col-sm-2 control-label">属性规则描述：</label>
			  <div class="col-sm-3">
	             <textarea rows="15" class="form-control" name="t.description">${t.description}</textarea>
			  </div>
		  </div>
		  <div class="form-group">
			  <label for="" class="col-sm-offset-3 col-sm-2 control-label">属性规则：</label>
			  <div class="col-sm-3">
	             <textarea rows="15" class="form-control" name="t.regex" id="regex">${t.regex}</textarea>
			  </div>
		  </div>
			
	
	      <c:if test="${!empty method}" >
	          <input name="method" type="hidden" value="${method }">
			  <input type="hidden" name="t.id" value="${t.id}">
		  </c:if>
			 
		  <div class="form-group">
		      <div class="col-sm-offset-5 col-sm-7">
		          <button type="submit" class="btn btn-default">提交</button>
		          <button type="reset" class="btn btn-default">重置</button>
		      </div>
		  </div>
	  </form>
    
  </div>
  
</div>

</body>
</html>
